# -*- coding: utf-8 -*-
# @name             : 回调通知
# @author           : OneYoung
# @create           : 2024/07/18
# @version          : v1.0
# @desc             : 监听回调通知信息并记录到日志

import json
import uvicorn
from fastapi import FastAPI
from utils.log_record import logger

app = FastAPI()


@app.post('/notice/callback', summary='监听回调通知信息')
async def notice_callback(data: dict | None):
    if isinstance(data, dict):
        data = json.dumps(data, indent=4, ensure_ascii=False)
    logger.info(f'接收回调通知信息：{data}')
    return {
        "code": 200,
        "msg": '成功',
        "data": data
    }


if __name__ == '__main__':
    uvicorn.run('callbacks:app', host='0.0.0.0', port=8002)
